// ["Vue", "React", "Nuxt", "NextJS", "Node", "NestJS", "React Native", "Electron", "Rust"]

const { createApp } = Vue;

const app = {
  data() {
    return {
      inputValue: "",
      todoList: [],
    };
  },
  methods: {
    addTodo() {
      if (this.inputValue.trim().length === 0) {
        alert("请输入内容");
        this.inputValue = "";
        return;
      }

      this.todoList.push({name: this.inputValue, done: false});
      this.inputValue = "";
    },
    // removeTodo(index) {
    //   this.todoList.splice(index, 1);
    // },
    removeTodo(index) {
      this.todoList = this.todoList.filter(
        (_, todoIndex) => todoIndex !== index
      );
    },
    completeTodo(index) {
      this.todoList[index].done = true;
    },

  },
};

createApp(app).mount("#app");
